<template>
	<view class="mine" v-cloak>
		<view class="mine-bg"></view>
		<uni-nav-bar statusBar="true" backgroundColor="transparent" :border="false"></uni-nav-bar>
		<view class="mine-header">
			<image :src="info.avatar" mode="aspectFill" class="header-logo"></image>
			<view class="header-info">
				<view class="h2">{{ info.nickName }}</view>
				<view class="info-tags">
					<image
					    v-if="member.isMember"
						:src="'https://fine-yahe.oss-cn-shanghai.aliyuncs.com/app/member' + configCard[member.level].icon"
						mode="aspectFill"
						style="width: 86rpx; height: 30rpx"
					></image>

					<!-- <view class="tags-item" >{{member.userLevelDesc || ''}}</view> -->
					<view class="tags-item" v-if="!member.isMember" @click="handleToUrl('/mineComponentPackage/component/member/index')">
						点亮荷花
						<uni-icons type="right" size="10" style="color: #fff;margin-left:4rpx" color="#fff"></uni-icons>
					</view>
				</view>
			</view>
			<view class="header-handle">
				<image src="@/static/mine/qrcode@2x.png" class="img" mode="aspectFill" @click="jump('/mineComponentPackage/component/dimensionalCode/index')"></image>
				<button class="button" open-type="contact">
					<image src="@/static/contact-white.png" class="img" mode="aspectFill"></image>
				</button>
				<image @click="handleToSetting()" src="@/static/setting-white.png" class="img" mode="aspectFill"></image>
			</view>
		</view>
		<view class="mine-main">
			<div class="main-card">
				<view class="card-ad" v-if="!member.isMember">
					<view class="ad-info">
						<view class="h2">成为牙荷体验官，享受专属福利</view>
						<view class="p">最低99元，全城免费洁牙一次</view>
					</view>
					<view class="ad-button" @click="handleToUrl('/mineComponentPackage/component/member/index')">成为体验官</view>
				</view>
				<view class="card-ad" v-else>
					<view class="ad-info">
						<view class="h2">{{ member.userLevelDesc }}</view>
						<view class="p">{{ member.memberDateStr }}</view>
					</view>
					<view class="ad-button" @click="handleToUrl('/mineComponentPackage/component/member/memberLevel')">会员中心</view>
				</view>
				<view class="card-list">
					<view class="list-item" @click="handleToUrl('/mineComponentPackage/component/lianmi')">
						<view class="num">{{ content.totalPrice || 0 }}</view>
						<view class="label">莲米</view>
					</view>
					<view class="list-item" @click="handleToUrl('/mineComponentPackage/component/coupon')">
						<view class="num">{{ content.voucher || 0 }}</view>
						<view class="label">优惠券</view>
					</view>
					<view class="list-item" @click="handleToUrl('/mineComponentPackage/component/lotus/index')">
						<view class="num">{{ content.lotusCount || 0 }}</view>
						<view class="label">荷花</view>
					</view>
					<view class="list-item" @click="handleToUrl('/mineComponentPackage/component/friend/index')">
						<view class="num">{{ content.lotusFriend || 0 }}</view>
						<view class="label">荷友</view>
					</view>
					<!-- <view class="list-item" @click="handleToUrl('/mineComponentPackage/component/pocket/index')"> -->
					<image
						src="@/static/mine/荷包title@2x.png"
						mode="scaleToFill"
						class="imgTitle"
						style="width: 214rpx; height: 108rpx"
						@click="handleToUrl('/mineComponentPackage/component/pocket/index')"
					></image>
					<!-- </view> -->
					<!-- <view class="list-item">
            <view class="num">95</view>
            <view class="label">积分</view>
          </view> -->
				</view>
			</div>

			<view class="main-order">
				<view class="order-title">
					我的订单
					<view class="title-span" @click="handleToOrder(0)">
						全部
						<uni-icons type="right" size="14" color="#6D6D6D"></uni-icons>
					</view>
				</view>
				<view class="order-list">
					<view class="list-item" @click="handleToOrder(1)">
						<image src="@/static/mine/待付款@2x.png" mode="aspectFill" class="img"></image>
						待付款
					</view>
					<view class="list-item" @click="handleToOrder(2)">
						<image src="@/static/mine/待收货@2x.png" mode="aspectFill" class="img"></image>
						待收货/待使用
					</view>
					<view class="list-item" @click="handleToOrder(4)">
						<image src="@/static/mine/待评价@2x.png" mode="aspectFill" class="img"></image>
						待评价
					</view>
					<view class="list-item" @click="handleToOrder(5)">
						<image src="@/static/mine/退款@2x.png" mode="aspectFill" class="img"></image>
						退款/售后
					</view>
				</view>
			</view>

			<view class="main-banner" @click="jump('/mineComponentPackage/ambassador/index')">
				<image src="https://fine-yahe.oss-cn-shanghai.aliyuncs.com/app/enterpriseCenter/ayds2x.png" mode="aspectFill" class="img"></image>
			</view>

			<view class="main-cate">
				<view class="title">推荐服务</view>
				<view class="cate-list">
					<view class="list-item" @click="handleToUrl('/mineComponentPackage/serviceCentre/index')">
						<image src="@/static/mine/入驻牙荷@2x.png" mode="aspectFill" class="img"></image>
						入驻牙荷
					</view>
					<!-- <view class="list-item" @click="handleToUrl('/mineComponentPackage/component/coupon')">
						<image src="@/static/mine/领劵中心@2x.png" mode="aspectFill" class="img"></image>
						领劵中心
					</view> -->
					<!-- <view class="list-item">
						<image src="@/static/mine/我的荷包@2x.png" mode="aspectFill" class="img"></image>
						我的荷包
					</view> -->
					<view class="list-item" @click="jumpList('/pages/other/shop-inline')">
						<image src="@/static/mine/积分@2x.png" mode="aspectFill" class="img"></image>
						莲米商城
					</view>
					<!-- 	<view class="list-item">
						<image src="@/static/mine/我的协议@2x.png" mode="aspectFill" class="img"></image>
						我的协议
					</view> -->
					<view class="list-item" @click="handleToUrl('/mineComponentPackage/component/classroom')">
						<image src="@/static/mine/牙荷学堂@2x.png" mode="aspectFill" class="img"></image>
						牙荷学堂
					</view>
				</view>
			</view>

			<view class="main-cate" v-if="false">
				<view class="title">猜你喜欢</view>
				<view class="likeList">
					<image src="/static/gray.jpg" mode=""></image>
					<image src="/static/gray.jpg" mode=""></image>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
import { configCard } from '@/mineComponentPackage/component/member/config.js';
export default {
	data() {
		return {
			configCard,
			member: {},
			info: {},
			content: {}
		};
	},
	onShow() {
		this.user = uni.getStorageSync('user');
		this.$post('/yahe/level/user').then((res) => {
			this.member = res.content;
		});
		this.$post('/yahe/level/userAccount').then((res) => {
			this.content = res.content;
		});

		this.info = uni.getStorageSync('user');
	},
	methods: {
		jumpList(url) {
			console.log(url, 444);
			uni.switchTab({
				url
			});
		},
		handleToUrl(url) {
			console.log(url, 4444);
			uni.navigateTo({
				url
			});
		},
		handleToSetting() {
			uni.verifyLogin();
			this.handleToUrl('/pages/mine/index');
		},
		handleToOrder(e) {
			uni.verifyLogin();
			this.handleToUrl(`/minePackage/order-list?tab=${e || 0}`);
		},
		jump(url) {
			uni.navigateTo({
				url
			});
			return;
			if (this.member.isMember) {
				uni.navigateTo({
					url
				});
			} else {
				uni.navigateTo({
					url: '/mineComponentPackage/component/member/index'
				});
			}
		}
	}
};
</script>

<style lang="less" scoped>
.mine {
	padding-bottom: 50rpx;
	.mine-bg {
		width: 100%;
		height: 360rpx;
		background: var(--theme-color);
		position: absolute;
		top: 0;
		left: 0;
		right: 0;
	}

	.mine-header {
		display: flex;
		align-items: center;
		padding: 8rpx 24rpx;
		color: #fff;
		position: relative;
		z-index: 10;

		.header-logo {
			width: 108rpx;
			height: 108rpx;
			border-radius: 50%;
			border: 4rpx solid rgba(255, 255, 255, 0.4);
		}

		.header-info {
			flex: 1;
			margin-left: 28rpx;
			margin-right: auto;

			.h2 {
				font-size: 28rpx;
				font-weight: bold;
			}

			.info-tags {
				margin-top: 8rpx;
				display: flex;
				align-items: center;

				.tags-item {
					line-height: 1;
					padding: 8rpx 12rpx;
					background: rgba(0, 0, 0, 0.14);
					border-radius: 58rpx 58rpx 58rpx 58rpx;
					margin-right: 6rpx;
					font-size: 20rpx;
				}
			}
		}

		.header-handle {
			display: flex;
			align-items: center;

			.button {
				margin: 0 28rpx;
				line-height: 1;
				padding: 0;
			}

			.img {
				width: 64rpx;
				height: 64rpx;
				display: block;
			}
		}
	}

	// mine-header end

	.mine-main {
		margin-top: 18rpx;
		padding: 0 24rpx;
		position: relative;
		z-index: 11;
	}

	.main-card {
		background: linear-gradient(176deg, #e5fffd 0%, #ffffff 24%, #ffffff 100%);
		box-shadow: 0rpx 6rpx 6rpx 0rpx rgba(0, 0, 0, 0.04);
		border-radius: 20rpx;
		overflow: hidden;

		.card-ad {
			display: flex;
			align-items: center;
			background: linear-gradient(90deg, #ffe3d6 0%, #fff4e2 100%);
			padding: 20rpx 30rpx 10rpx;

			.ad-info {
				.h2 {
					font-size: 24rpx;
					color: var(--title-color);
					margin-bottom: 4rpx;
				}

				.p {
					font-size: 20rpx;
					color: #f07676;
				}
			}

			.ad-button {
				height: 56rpx;
				line-height: 56rpx;
				background: linear-gradient(90deg, #ffad6a 0%, #ff7745 100%);
				color: #fff;
				font-size: 24rpx;
				padding: 0 20rpx;
				border-radius: 100rpx;
				margin-left: auto;
			}
		}

		.card-list {
			display: flex;
			align-items: center;
			// padding: 20rpx 0;
			// justify-content: space-evenly;
			justify-content: space-between;
			padding-left: 30rpx;

			.list-item {
				font-size: 24rpx;
				color: #6d6d6d;
				text-align: center;

				.num {
					font-size: 28rpx;
					font-weight: bold;
					color: var(--title-color);
					margin-bottom: 8rpx;
				}

				.imgTitle {
					width: 214rpx;
					height: 107rpx;
				}
			}
		}
	}

	// main-card end

	.main-order {
		margin-bottom: 24rpx;

		.order-title {
			display: flex;
			align-items: center;
			font-size: 28rpx;
			color: var(--title-color);
			line-height: 88rpx;
			font-weight: bold;

			.title-span {
				display: flex;
				align-items: center;
				font-weight: 400;
				font-size: 24rpx;
				color: #6d6d6d;
				margin-left: auto;
			}
		}

		.order-list {
			display: flex;
			align-items: center;
			justify-content: space-evenly;

			.list-item {
				font-size: 24rpx;
				color: var(--title-color);
				text-align: center;

				.img {
					display: block;
					width: 76rpx;
					height: 76rpx;
					margin: 0 auto;
					margin-bottom: 12rpx;
				}
			}
		}
	}

	// main-order end

	.main-banner {
		width: 100%;
		height: 98rpx;
		border-radius: 98rpx;
		overflow: hidden;

		.img {
			width: 100%;
			height: 100%;
		}
	}

	.main-cate {
		.title {
			font-size: 28rpx;
			color: var(--title-color);
			line-height: 88rpx;
			font-weight: bold;
		}
		.likeList {
			display: flex;
			flex-wrap: wrap;
			border: 20rpx;
			gap: 30rpx;
			image {
				width: 47%;
				height: 300rpx;
				border-radius: 20rpx;
			}
		}
		.cate-list {
			padding: 0 36rpx;
			display: flex;
			flex-wrap: wrap;

			.list-item {
				width: 33%;
				display: flex;
				align-items: center;
				margin-bottom: 12rpx;
				font-size: 24rpx;
				color: var(--title-color);

				.img {
					width: 56rpx;
					height: 56rpx;
					margin-right: 8rpx;
				}
			}
		}
	}
}
</style>
